package org.main.userprovider.controller;

import org.main.bean.POJO.PAddress;
import org.main.bean.POJO.PUser;
import org.main.bean.POJO.Pgwc;
import org.main.bean.entity.Gwc;
import org.main.userprovider.Dao.PGWCDAO;
import org.main.userprovider.Dao.PUserDao;
import org.main.userprovider.Dao.UserDao;
import org.main.userprovider.Dao.gwcDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * By： 土豆菌
 * 2019-03-01 0:32
 */
@RestController
@RequestMapping("/gwc")
public class PgwcCOntroller {
    @Autowired
    private PGWCDAO pgwcdao;
    @Autowired
    private gwcDao gwcDao;
    @RequestMapping("/query/{userId}/{goodsId}/{goodsShu}/{goodsDj}")
    public String insert(@PathVariable("userId") int userId,@PathVariable("goodsId") int goodsId,@PathVariable("goodsShu") String goodsShu,@PathVariable("goodsDj") String goodsDj){
        String msg ="成功";
        Gwc gwc=new Gwc(userId,goodsId,goodsShu,goodsDj);

        try {
            gwcDao.save(gwc);
        } catch (Exception e) {
            msg = "失败";
        }
        return msg;
    }

    @RequestMapping("/query/{userId}")
    public List<Pgwc> getOne(@PathVariable("userId") int userId){
        return pgwcdao.getAlls(userId) ;
    }


}
